package brad.zimmerman.dungeon.game;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ClassGridAdapter extends BaseAdapter  {
	private Context context;
	private final ClassStringandPictureHolder iconArray;
 
	public ClassGridAdapter(Context context, ClassStringandPictureHolder iconArray) {
		this.context = context;
		this.iconArray = iconArray;
	}
 
	public View getView(int position, View convertView, ViewGroup parent) {
 
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View gridView;
 
		if (convertView == null) {
 
			gridView = new View(context);
 
			// get layout from mobile.xml
			gridView = inflater.inflate(R.layout.prize, null);
 
			// set value into textview
			TextView textView = (TextView) gridView
					.findViewById(R.id.grid_item_label);
			textView.setText(iconArray.getIndex(position).getTitle());
 
			// set image based on selected text
			ImageView imageView = (ImageView) gridView
					.findViewById(R.id.grid_item_image);
 
			imageView.setImageResource(iconArray.getIndex(position).getPicture());
 
		} else {
			gridView = (View) convertView;
		}
 
		return gridView;
	}
 
	//@Override
	public int getCount() {
		return iconArray.getSize();
	}
 
	//@Override
	public Object getItem(int position) {
		return null;
	}
 
	//@Override
	public long getItemId(int position) {
		return 0;
	}
}
